package cn.avalon.basic.config;

import cn.avalon.user.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @description: 配置拦截器
 * @author: Avalon
 * @date: 2022年08月27日 ： 15:48
 * @version: ver1.0
 * @email 709785494@qq.com
 */
@Configuration
public class MyWebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(loginInterceptor)
                // 拦截所有请求
                .addPathPatterns("/**")

                // 放行登录
                .excludePathPatterns("/login/**")

                // 放行注册
                .excludePathPatterns("/user/register/**","/shop/settlement","/verifyCode/**","/fastDfs/**","/user/register/email/activate/")

                //放行swagger
                .excludePathPatterns("/swagger-resources/**", "/webjars/**","/v2/**", "/swagger-ui.html/**");

    }
}
